package jdk5.generic;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Date;
import java.util.Calendar;

import jdk5.common.Student;
import static  java.util.Calendar.*;

public class GroupMgmt{
	
      public static Date mkDate(int year, int month, int day){
                Calendar cal = Calendar.getInstance();
                cal.set(YEAR, year);
                cal.set(MONTH, month - 1);
                cal.set(DAY_OF_MONTH, day);

                return cal.getTime();
      }
         
       public static void main(String[] args){
              HashMap<Integer, Group> gmap = new HashMap<Integer, Group>();
              Group g = new Group();
              g.join(new Student("George", "Male",  mkDate(1970, 3, 21) ));
              gmap.put(1, g);

             Group g0 = new Group();
             g0.join(new Student("Larry", "Male",  mkDate(1966, 2, 11) ));
             g0.join(new Student("Mary", "Female",  mkDate(1974, 6, 2) ));
             gmap.put(2, g0);

             Group group = gmap.get(1);
             Iterator<Student> i = group.iterator();
            while(i.hasNext()){
                    System.out.println(i.next().getName());
             }
      }
}

